<template>
  <div class="content_box">
    <div class="nr">
      <div class="box">
        <p>加盟模式</p>
        <van-radio-group
          v-model="query.mode"
          bind:change="onChange"
          direction="horizontal"
        >
          <van-radio name="1"><span>独立加盟</span></van-radio>
          <van-radio name="2"><span>共创开店</span></van-radio>
        </van-radio-group>
      </div>
      <div class="box">
        <p>开店预算</p>
        <van-radio-group
          v-model="query.budget"
          bind:change="onChange"
          direction="horizontal"
        >
          <van-radio name="1"><span>10-15</span></van-radio>
          <van-radio name="2"><span>15-25</span></van-radio>
          <van-radio name="3"><span>25以上</span></van-radio>
        </van-radio-group>
      </div>
      <div class="box">
        <p>是否体验过杠小二线下门店</p>
        <van-radio-group
          v-model="taste1"
          bind:change="onChange"
          direction="horizontal"
        >
          <van-radio name="1"><span>是</span></van-radio>
          <van-radio name="2"><span>否</span></van-radio>
        </van-radio-group>
      </div>
      <div class="box">
        <p>姓名</p>
        <input v-model="query.name" type="text" placeholder="请输入">
      </div>
      <div class="box">
        <p>电话</p>
        <input v-model="query.phone" type="text" placeholder="请输入">
      </div>
      <div class="box">
        <p>所在城市</p>
        <input v-model="query.city" type="text" placeholder="请输入">
      </div>
    </div>

    <div class="button_box" :style="{paddingBottom:isIphoneXnum+'px'}">
      <div class="box">
        <van-button 
          @click="submit"
          :disabled="loading"
          :loading="loading" 
          loading-text="提交中..."
          type="primary"
          color="#3d98f7"
          custom-style="font-family: PingFangSC-Regular, PingFang SC;border:none;width: 690rpx;height:80rpx;line-height: 80rpx;background: #00C200;border-radius: 40rpx;text-align: center;color: #fff;font-size: 32rpx;"
        >确认提交</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { 
  getToken,
} from "@/utils/auth";
import { addCooperate } from "@/api/index";
export default {
  data() {
    return {
      statusBarHeight: "", // 状态栏高度
      titleBarHeight: "", // 标题栏高度
      navBarHeight: "", // 导航栏总高度
      radio: '1',
      loading:false,
      query:{
        mode:'1',
        city:'',
        name:'',
        phone:'',
        taste:'',
        budget:'1'
      },
      taste1:'1'
    };
  },
  methods: {
   
    submit(){
      //console.log(this.query)
      this.loading = true
      this.query.taste = this.taste1 == '1'?true:false
      this.$showLoading('提交中...')
      addCooperate(this.query).then(res=>{
        if(res.statusCode == '00000'){
          setTimeout(() => {
            wx.redirectTo({
              url: "/pages/jiameng/success/main",
            });
          }, 1000);
        }else{
          this.loading = false
          this.$toast(res.message)
        }
      })
    }
  },
  onShow(){
    this.loading = false
  },
  onLoad(options) {
    this.query = {
      mode:'1',
      city:'',
      name:'',
      phone:'',
      taste:'',
      budget:'1'
    }
  },
  beforeMount() {
    const self = this;
    wx.getSystemInfo({
      success(system) {
        //console.log(`system:`, system);
        self.statusBarHeight = system.statusBarHeight;
        let platformReg = /ios/i;
        if (platformReg.test(system.platform)) {
          self.titleBarHeight = 44;
        } else {
          self.titleBarHeight = 48;
        }
        self.navBarHeight = self.statusBarHeight + self.titleBarHeight;
      },
    });
  },
};
</script>

<style lang="scss" scoped>
.content_box {
  min-height: 100vh;  
  padding:32rpx;
  background: linear-gradient(180deg, rgba(0,194,0,0.6) 0%, #f5f5f5 100%);
  .nr{
    padding:30rpx 24rpx;
    background: #fff;
    border-radius: 16rpx;
    margin-bottom:150rpx;
    .box{
      padding:24rpx;
      background: #F6F9FF;
      border-radius: 8rpx;
      margin-bottom:24rpx;
      font-size: 30rpx;
      font-family: PingFangSC-Medium, PingFang SC;
      color: #111111;
      &:last-child{
        margin-bottom:0;
      }
      p{
        margin-bottom: 32rpx;
      }
      span{
        font-size: 28rpx;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #666666;
      }
      /deep/ .van-radio{
        margin-right:50rpx;
      }
      /deep/ .van-radio__icon--checked{
        background: #00C200;
        border-color:#00C200;
      }
      input{
        border:1px solid #aaa;
        border:none;
      }
    }
  }
 
  

  .button_box{
    width: 100%;
    height: 120rpx;
    position: fixed;
    bottom:0;
    left:0;
    background: #fff;
    .box{
      width: 92%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin:0 auto;
      .anniu{
        width: 100%;
        height: 80rpx;
        line-height: 80rpx;
        background: #b4e8b4;
        box-shadow: 0rpx -2rpx 2rpx 0rpx rgba(0,0,0,0.02);
        border-radius: 40rpx;
        font-size: 32rpx;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        text-align: center;
      }
    }
  }
}

</style>